#include <QtPlugin>

#include <QVBoxLayout>
#include <QSpinBox>
#include <QCheckBox>
#include <QWidget>
#include <QLineEdit>
#include <QComboBox>
#include <QPushButton>

#include <opencv/cv.h>
#include <opencv/highgui.h>

#include "QCVModuleInterface.h"
#include "QCVModuleHandlerInterface.h"
#include "QCVGraph.h"

#include <iostream>

#ifndef MODULE_EMD
#define MODULE_EMD

class ModuleEMD:public QObject,QCVModuleInterface
{
  Q_OBJECT
	Q_INTERFACES(QCVModuleInterface)
	
	public:
		void init(QCVModuleHandlerInterface * parent);
		void free();

		cv::Mat & process();
		void setInput(int n,const cv::Mat & m);

		QWidget* widget();
		QString getName();
		int nbInputs();
		QString help(int id);
		bool setParams(QString params);
    QString getParams();
		QCVModuleInterface * clone();
		
	private slots:
		void s_use_graph(int state);		
		void s_costMatStd();
		void s_adjMatStd();

	private:  
    QWidget * win;
    QVBoxLayout * layout;
		QSpinBox * sb_delay;
		QLineEdit * le_EMD;
		QPushButton * pb_costMatStd,*pb_adjMat;

		cv::Mat_<float> emd;
		cv::Mat_<float> costMat;
		cv::Mat_<float> hist1,hist2;
		cv::Mat_<float> adjMat;
		
		QCheckBox * cb_useConnexGraphDistance;

		QCVModuleHandlerInterface * parent;
};

#endif
